//package com.micro.common.service.web.mq.producer;
//
//import com.alibaba.fastjson.JSON;
//import com.micro.framework.starter.rocket.message.OrderMessage;
//import com.micro.framework.starter.rocket.producer.RocketMQProducer;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.rocketmq.client.producer.SendResult;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.annotation.Transactional;
//
//import javax.annotation.Resource;
//@Component
//@Slf4j
//public class TradeProducer {
//    @Resource(name = "rocketMQInstance-1")
//    private RocketMQProducer rocketMQProducer;
//
//
//    private final String topic = "ybx_test";
//
//
//    @Transactional(rollbackFor = Exception.class)
//    public void manualRecovery() {
//        TradeMsg changeMsg = TradeMsg.builder()
//                .coinTradeType(0)
//                .coinTradeCode("FF202504090028")
//                .coinTradeId("826146173399306242")
//                .msgType("send_commit_approval")
//                .tradeType("send").build();
//        changeMsg.setShardingKey("826146173399306242");
//        changeMsg.setCreateUserWanxin("yanshouzhong");
//        sendMsg(changeMsg);
//    }
//
//
//
//    /*
//     *  发送消息失败一定不能吞掉异常。业务方法触发回滚操作
//     */
//    private void sendMsg(TradeMsg changeMsg) {
//
//        OrderMessage message = new OrderMessage();
//        changeMsg.setMsgId(changeMsg.getCoinTradeId());
//        message.setShardingKey(changeMsg.getShardingKey());
//        message.setTopic(topic);
//        message.setBody(JSON.toJSONString(changeMsg));
//        SendResult sendResult = rocketMQProducer.sendOrderMessage(message);
//        log.info("sendResult {}",JSON.toJSONString(sendResult));
//    }
//
//
//
//}
